/**
 * Description:一些注释<br/>
 * CreateTime:2019-04-16<br/>
 * Creater: yangpengfei360@126.com <br/>
 * @author yangpengfei
 */
package cn.cnsy123.bookwebsiteserver.validator.impl;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import cn.cnsy123.bookwebsiteserver.validator.IpAddrValidator;

/**
 * Description:一些注释<br/>
 * CreateTime:2019-04-16<br/>
 * Creater: yangpengfei360@126.com <br/>
 * @author yangpengfei
 */
public class IpAddrValidatorImpl implements ConstraintValidator<IpAddrValidator, String>{

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        final String regex = "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\."

+"(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."

+"(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."

+"(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$";
        return value.matches(regex);
    }

}
